{extend name="public:base" /}
{block name="head"}
<link href="__PUBLIC__/view_res/mobile/css/uc.css" type="text/css" rel="Stylesheet" />
<link href="__PUBLIC__/view_res/mobile/css/wshop_company_center.css" type="text/css" rel="Stylesheet" />
<link href="__PUBLIC__/jquery-weui/dist/lib/weui.min.css" type="text/css" rel="Stylesheet" />
<link href="__PUBLIC__/view_res/mobile/css/login.css" type="text/css" rel="Stylesheet" />
<link href="__PUBLIC__/jquery-weui/dist/css/jquery-weui.min.css" type="text/css" rel="Stylesheet" />
<script src="__PUBLIC__/jquery-weui/dist/js/jquery-weui.min.js"></script>
<link rel="stylesheet" href="__PUBLIC__/bootstrap-3.3.7-dist/css/bootstrap.min.css">
<!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">

<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
<script src="https://cdn.jsdelivr.net/npm/bootstrap@3.3.7/dist/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>

{/block}
{block name="header"}
{include file="public/top-nav" /}
{/block}
{block name="content"}
<style media="screen">
    body{
        background-color: #efeff4
    }
    .card{
        font-size: 14px;
        margin: 10% 0 10% 10%;
        width: 80%;
        overflow: hidden;
        border-radius: 2px;
        background-color: #fff;
        background-clip: padding-box;
        box-shadow: 0 1px 2px rgba(0,0,0,.3);
        padding: 10px;
        color: #8f8f94;
        font-weight:bold;
    }
    .card .card_title{
        font-size: 20px;
        font-weight: 400;
        text-align: center;
        line-height: 60px;
    }
    .card p{
        font-size: 12px;
    }
    .card .title{
        border-left: 2px solid #4ab8ec;
        font-size: 16px;
        line-height: 16px;
        padding-left: 4px;
        margin: 10px 4px;
        color: #000;
    }
    input[type="radio"]:checked + label{
        background-color: #e33235;
        color: #fff;
        border-color: #e33235;
    }
    input[type="radio"] {
        position: absolute;
        clip: rect(0, 0, 0, 0);
    }
    input[type="submit"] {
        width:100%;margin-top:20px;
    }
    .card .button{
        display: inline-block;
        vertical-align: middle;
        width: 48.5%;
        position: relative;
        padding: 6px 0px;
        margin: 4px 1px;
        font-size: 12px;
        font-weight: 400;
        line-height: 1.42;
        color: #333;
        text-align: center;
        white-space: nowrap;
        cursor: pointer;
        background-color: #fff;
        background-clip: padding-box;
        border: 1px solid #ccc;
        border-radius: 3px;
        -webkit-transition: all;
        transition: all;
        -webkit-transition-timing-function: linear;
        transition-timing-function: linear;
        -webkit-transition-duration: .2s;
        transition-duration: .2s;
    }
</style>
<div class="card">
    {:token()}
    <h5 class="card_title">
    合约申请
    </h5>
        {if condition="$free.state eq 0 and $free neq null"}
        <p class="title" style="color: red">您申请正在合约正在审核，请等待进场时间通知</p><br>
        {/if}
    <p class="title">当前可用金额</p>
    <div class="button_list info">
        <label style="border:0" class="button">金豆：{$user.predeposit}</label>
        <label style="border:0" class="button">元宝:{$user.jilin_bean}</label>
    </div>

    <p class="title">申请金额</p>
    <div class="button_list info">
        <input class="button money" style="width: 100%"  type="number" name="money" id="money" value="{$free.money}" placeholder="请输入申请金额（交易所买入金额）"><br>
        <label style="border:0" class="button">*最低申请金额：1000</label>
    </div>

    <p class="title">选择提货抵扣方式</p>
    <div class="button_list info">

        <input class="click info_radio" type="radio" name="integral" id="predeposit" value="1" {if condition="$free.type eq 1 and $free neq null"} checked {/if}>
        <label for="predeposit"  class="button">金豆</label>
        <input class="click info_radio" type="radio" name="integral" id="jilin_bean" value="2" {if condition="$free.type eq 2 and $free neq null"} checked {/if}>
        <label for="jilin_bean"   class="button">元宝</label>
    </div>



    <p class="title">合约承诺</p>
    <div class="button_list" style="margin-bottom: 10%">
        <label class="button" id="rate_rate">0.3</label>
    </div>
    {if condition="$free eq null"}
    <input type="submit" value="提交" class=" btn btn-primary "  style="display: block" >
    {/if}
</div>

<script>

    $(document).ready(function(){
        var ipt = $('#money');
        ipt.on('keyup',function(){
            if(! /^\d+$/.test(this.value)){
                this.value=parseInt(this.value);
            }
        })
    });


    $('.btn').click(function(){
        var money = $('.money').val();
        var token = $('input[name="__token__"]').val();
        var integral = $('.button_list input[name="integral"]:checked ').val();

        if(money == undefined || money == ''){
            $.toast('请填写申请金额', "forbidden");
            return false;
        }

        var l = "注意事项： \r"
        +"    1.如实际购买金额小于申请金额，根据实际购买金额计算收益（收益为实际购买金额的30%），使用的金豆或元宝不予退回。 \r"
        +"    2.如实际购买金额大于申请金额，根据申请金额的计算收益（收益为申请金额的30%）。 \r"
        +"    3.卖出凭证枚数必须等于或大于提交买入凭证的实际枚数，如小于买入凭证的枚数，视为合约作废。 \r"
        +"    4.要求当日入场的合约，未上传当日买入凭证者，视为自动放弃合约，使用的金豆和元宝不予退回。 ";

        var con = confirm(l);

        if(con == true){
            $.ajax({
                url: "{:url('contract/free_apply')}",
                type:'post',
                data: {money:money,token:token,integral:integral},
                success: function(data){
                    if(data.code == 1){
                        $.toast(data.msg);
                        setTimeout(function (){
                            window.location.href = "/mobile/contract/free_apply";
                        },1000);
                    }else{
                        $.toast(data.msg, "forbidden");
                    }
                }
            });
        }

    });

</script>
{/block}
{block name="script"}
{/block}
